<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>添加分类</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
          content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="${global_templets_skin}/systemstyle/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="${global_templets_skin}/systemstyle/style/admin.css" media="all">
    <script src="${global_templets_skin}/common/js/jquery.min.js"></script>
    <script src="${global_templets_skin}/systemstyle/layui/ztree/jquery.ztree.core-3.5.min.js"></script>
</head>
<body>

<div class="layui-fluid">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md12">
            <div class="layui-card">
                <div class="layui-card-header">网站分类</div>
                <div class="layui-card-body">
                    <div class="layui-form" lay-filter="">
                        <div class="layui-tab">
                            <ul class="layui-tab-title">
                                <li class="layui-this">常规选项</li>
                                <li class="">高级选项</li>
                            </ul>
                            <div class="layui-tab-content">
                                <div class="layui-tab-item layui-show">
                                    <div class="layui-form-item">
                                        <label class="layui-form-label">上级分类</label>
                                        <div class="layui-input-inline">
                                            <input type="text" placeholder="选择分类" value="${parentName!}" id="columnform" autocomplete="off" class="layui-input">
                                            <input type="hidden" name="parentId" id="parentId" value="${parentId!}" class="layui-input">
                                            <div class="layui-form-mid layui-word-aux">请勿选择当前分类或者当前分类下属类别</div>
                                        </div>
                                    </div>
                                    <div class="layui-form-item">
                                        <label class="layui-form-label">分类名称</label>
                                        <div class="layui-input-block">
                                            <div class="layui-col-md6">
                                                <input type="text" name="columnTitle" value="" lay-verify="required" placeholder="分类名称" class="layui-input">
                                            </div>
                                        </div>
                                    </div>
                                    <div class="layui-form-item">
                                        <div class="layui-inline">
                                            <label class="layui-form-label">转向链接</label>
                                            <div class="layui-input-inline">
                                                <input type="tel" name="columnUrl" autocomplete="off" class="layui-input">
                                            </div>
                                        </div>
                                        <div class="layui-inline">
                                            <label class="layui-form-label">新窗口打开</label>
                                            <div class="layui-input-inline">
                                                <select name="newWindow" lay-search="">
                                                    <option value="1"  checked>是</option>
                                                    <option value="0">否</option>
                                                </select>
                                            </div>
                                        </div>
                                    </div>
                                    <div class="layui-form-item layui-form-text">
                                        <label class="layui-form-label">栏目模型</label>
                                        <div class="layui-input-inline">
                                            <select name="channel" lay-filter="channel" lay-verify="required" lay-search="">
                                                <option value="">请选择该栏目使用的模型</option>
                                                <#list modulelist as list>
                                                <option value="${list.id!}">${list.moduleName!}</option>
                                                </#list>
                                            </select>
                                        </div>
                                    </div>
                                    <div class="layui-form-item">
                                        <label class="layui-form-label">是否隐藏栏目</label>
                                        <div class="layui-input-block">
                                            <input type="radio" name="columnHidden" value="1" title="显示" checked><div class="layui-unselect layui-form-radio"><i class="layui-anim layui-icon"></i><div>显示</div></div>
                                            <input type="radio" name="columnHidden" value="0" title="隐藏"><div class="layui-unselect layui-form-radio"><i class="layui-anim layui-icon"></i><div>隐藏</div></div>
                                        </div>
                                    </div>
                                    <div class="layui-form-item">
                                        <label class="layui-form-label">栏目属性</label>
                                        <div class="layui-input-block">
                                            <div class="layui-col-md12">
                                                <input type="radio" name="columnType" value="1" title="最终列表栏目（允许在本栏目发布文档）" checked><div class="layui-unselect layui-form-radio"><i class="layui-anim layui-icon"></i><div>最终列表栏目（允许在本栏目发布文档）</div></div>
                                            </div>
                                            <div class="layui-col-md12">
                                                <input type="radio" name="columnType" value="2" title="频道封面（栏目本身不允许发布内容）"><div class="layui-unselect layui-form-radio"><i class="layui-anim layui-icon"></i><div>频道封面（栏目本身不允许发布内容）</div></div>
                                            </div>
                                            <div class="layui-col-md12">
                                                <input type="radio" name="columnType" value="3" title="单独页面（栏目本身不允许发布内容）"><div class="layui-unselect layui-form-radio"><i class="layui-anim layui-icon"></i><div>单独页面（栏目本身不允许发布内容）</div></div>
                                            </div>
                                            <div class="layui-col-md12">
                                                <input type="radio" name="columnType" value="4" title="转跳网址（在栏目转跳表单填写完整网址）"><div class="layui-unselect layui-form-radio"><i class="layui-anim layui-icon"></i><div>转跳网址（在栏目转跳表单填写完整网址）</div></div>
                                            </div>
                                        </div>
                                    </div>
                                    <div class="layui-form-item">
                                        <div class="layui-input-block">
                                            <button class="layui-btn" lay-submit lay-filter="addsite">确认保存</button>
                                        </div>
                                    </div>
                                </div>
                                <div class="layui-tab-item">
                                    <div class="layui-form-item layui-form-text">
                                        <label class="layui-form-label">封面模板</label>
                                        <div class="layui-input-inline">
                                            <select name="tempindex" id="tempindex" lay-verify="required" lay-search="">
                                            </select>
                                        </div>
                                    </div>
                                    <div class="layui-form-item layui-form-text">
                                        <label class="layui-form-label">列表模板</label>
                                        <div class="layui-input-inline">
                                            <select name="templist" id="templist" lay-verify="required" lay-search="">
                                            </select>
                                        </div>
                                    </div>
                                    <div class="layui-form-item layui-form-text">
                                        <label class="layui-form-label">内容页面模板</label>
                                        <div class="layui-input-inline">
                                            <select name="tempcontent" id="tempcontent" lay-verify="required" lay-search="">
                                            </select>
                                        </div>
                                    </div>
                                    <div class="layui-form-item layui-form-text">
                                        <label class="layui-form-label">单独页面模板</label>
                                        <div class="layui-input-inline">
                                            <select name="tempalone" id="tempalone" lay-verify="required" lay-search="">
                                            </select>
                                        </div>
                                    </div>
                                    <div class="layui-form-item layui-form-text">
                                        <label class="layui-form-label">META关键词</label>
                                        <div class="layui-input-block">
                                             <textarea name="keywords" class="layui-textarea" placeholder="keywords数量应该控制在0-3个之间，最多不超过5个。如果一个非常专业的网站，设置一个keywords，多个关键词用英文状态 , 号分割"></textarea>
                                        </div>
                                    </div>
                                    <div class="layui-form-item layui-form-text">
                                        <label class="layui-form-label">META描述</label>
                                        <div class="layui-input-block">
                                            <textarea name="description" class="layui-textarea"  placeholder="出现核心的关键词，必须完整的出现在描述中。描述长度155个字符。"></textarea>
                                        </div>
                                    </div>
                                    <div class="layui-form-item">
                                        <div class="layui-input-block">
                                            <input type="hidden" name="siteId" id="siteId" value="${siteId!}">
                                            <button class="layui-btn" lay-submit lay-filter="addsite">确认保存</button>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

<script src="${global_templets_skin}/systemstyle/layui/layui.js"></script>
<script>
    layui.config({
        base: '${global_templets_skin}/systemstyle/' //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['index', 'set'], function () {
        var form   = layui.form
            ,$      = layui.jquery
            ,layer  = layui.layer;

        $(document).on('click', '#columnform', function (){
            var siteId = $('#siteId').val();
            layer.open({
                type: 2,
                title :'选择所属',
                fixed: false, //不固定
                maxmin: true,
                content: '/admin/system_column/columnform.do?siteId='+siteId,
            });
        });

        form.on('submit(addsite)', function(data) {
            $.ajax({
                url:'/admin/system_column/add.do',
                type:'post',
                dataType: 'json',
                data: data.field,
                success:function(e){
                    if (e.code == "0") {
                        layer.msg('成功');
                        window.location.reload();
                    }else {
                        layer.msg(e.message, {icon: 2});
                    }
                }
            })
            //防止页面跳转
            return false;
        });


        //监听select选择事件
        form.on('select(channel)', function(data){
            var channel=data.value,siteId = $('#siteId').val();
            $.ajax({
                type : "post",
                dataType: 'json',
                url : "/member/template/pagelist.do",
                data : {"channel":channel,"siteId":siteId},
                success : function(ev)
                {
                    $("#tempindex").empty();
                    for (var i = 0; i < ev.tempindex.length; i++) {
                        //如果在select中传递其他参数，可以在option 的value属性中添加参数
                        $("#tempindex").append("<option value='"+ev.tempindex[i].id+"'>"+ev.tempindex[i].templateName+"</option>");

                    }

                    $("#templist").empty();
                    for (var i = 0; i < ev.templist.length; i++) {
                        //如果在select中传递其他参数，可以在option 的value属性中添加参数
                        $("#templist").append("<option value='"+ev.templist[i].id+"'>"+ev.templist[i].templateName+"</option>");

                    }

                    $("#tempcontent").empty();
                    for (var i = 0; i < ev.tempcontent.length; i++) {
                        //如果在select中传递其他参数，可以在option 的value属性中添加参数
                        $("#tempcontent").append("<option value='"+ev.tempcontent[i].id+"'>"+ev.tempcontent[i].templateName+"</option>");

                    }

                    $("#tempalone").empty();
                    for (var i = 0; i < ev.tempalone.length; i++) {
                        //如果在select中传递其他参数，可以在option 的value属性中添加参数
                        $("#templist").append("<option value='"+ev.tempalone[i].id+"'>"+ev.tempalone[i].templateName+"</option>");

                    }
                    //这句话必加，不加不显示新增的option
                    form.render();
                },error:function(){
                    alert("获取数据失败","error");
                }
            });
        });
    });
</script>
</body>
</html>